#include <stdlib.h>
#include "errmsg.h"
#include "linkop.h"

/*int link_init(struct myftp_node **list)*/
/*{*/
/*    list = NULL;*/
/*    *list = NULL;*/
/*}*/

int link_add_element(struct myftp_node *list, void *element)
{
	struct myftp_node *new;
	struct myftp_node *tmp;

	tmp = list;

	if (malloc(sizeof(struct myftp_node)) == NULL) {
		err_quit("malloc error!");			
	}
	new->data = element;
	new->next = NULL;

	while (tmp->next) {
		tmp = tmp->next;	
	}
	tmp->next = new;
}

int link_del_element(struct myftp_node *list, void *element)
{
	if (!list->next) 
		return (-1);
	struct myftp_node *tmp;
	tmp = list;
	do {
		if (*tmp->data == *element)
			return 0;
	} while(tmp->next)
	
	return (-1);
}
int link_find_element(const struct myftp_node *list, void element)
{
	struct myftp_node *tmp;
	tmp = list;
	do{
		if (*(tmp->data) == element){
			return tmp;		
		} 	
		tmp = tmp->next;
	}while (tmp->next)
}
